
#include <BFont>
#include <BPainter>
#include <BStyle>
#include <BMouseEvent>

#include <BCheckBox>
#include "member_BButton.h"

using namespace BWE;

BCheckBox::BCheckBox(BWidget* parent) : BButton(parent)
{
	this->setAlign(Align_LeftCenter);
	this->setGraph(Graph_Space);
	this->setCheckable(true);
}
BCheckBox::BCheckBox(const BString& text, BWidget* parent) : BButton(text, parent)
{
	this->setAlign(Align_LeftCenter);
	this->setGraph(Graph_Space);
	this->setCheckable(true);
}
BCheckBox::~BCheckBox()
{

}

void BCheckBox::paintEvent(const BEvent& event)
{
	BButton::paintEvent(event);

	if (!button_member(this)->icon && button_member(this)->graph == Graph_Space)
	{
		BPainter painter(this);
		State state = button_member(this)->state;
		const BRect& imageRect = button_member(this)->alignment.ia_imageRect;
		if (state == State_Disable)
			painter.setColor(Color_Arrow_Disable);
		else if (state == State_Hovered)
			painter.setColor(Color_Arrow_Hovered);
		else
			painter.setColor(Color_Arrow);
		painter.setLineSmooth(true);
		painter.setLineWidth(2);
		painter.drawRect(imageRect % 86);
		if (button_member(this)->checked)
		{
			painter.drawGraph(imageRect % 66, Graph_Check);
		}
	}
}
